<!-- 首页 -->
<template>
  <div class="stbox">
    <!-- 面包屑导航 -->
    <div class="breadcrumb-title">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: 'assessment/assessmentList' }">考核管理</el-breadcrumb-item>
        <el-breadcrumb-item>考核结果分析</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="thinking-content">
      <!--考核分数 -->
      <div class="state-title">
        <div class="st-gbox" style="width:1200px;height: 450px;">
          <div class="cavasbox" ref="difficultychart"></div>
        </div>
      </div>
      <!-- 考核通过率-->
      <div class="state-title">
        <div class="st-gbox" style="width:500px;height: 300px;">
          <div class="cavasbox" ref="typechart"></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script type="text/ecmascript-6">
import Chart from 'echarts'
import { color } from 'echarts/lib/theme/light';
export default {
  name: "welcome",
  data() {
    return {
      machineNo: '',
      type: 'day',
      scoreData: [
        { name: '内科临床思维考核', value: 80 },
        { name: '外科临床思维考核', value: 82 },
        { name: '妇产科临床思维考核', value: 78 },
        { name: '儿科临床思维考核', value: 90 },
        { name: '神经科临床思维考核', value: 88 },
      ],
      // passRateData:[
      // {name: '通过', value: '80'},  
      // {name: '未通过', value: "10"}, 
      // {name: '优秀', value: "10"}, 
      // ],
      passRateData: {
        labels: ['通过', '未通过', '优秀'],
        datasets: [
          {
            data: [83, 7, 10],
            backgroundColor: ['rgba(75, 192, 192, 0.2)', 'rgba(255, 99, 132, 0.2)', 'rgba(153, 102, 255, 0.2)'],
            borderColor: ['rgba(75, 192, 192, 1)', 'rgba(255, 99, 132, 1)', 'rgba(153, 102, 255, 1)'],
            borderWidth: 1
          }
        ]
      }



    }
  },
  // 导入组件
  components: {
    // 点聚合组件
  },
  // 创建完毕状态(里面是操作)
  created() { },
  // 挂载结束状态(里面是操作)
  mounted() {
    this.getscoreData()
    this.drawPieChart()
  },
  // 里面的函数只有调用才会执行
  methods: {
    // 考核分数柱状图
    getscoreData() {
      let difficultyOption = {
        title: {
          text: '考核分数柱状图'
        },
        tooltip: {},
        xAxis: {
          data: this.scoreData.map(item => item.name),
        },
        yAxis: {
          axisLine: {
          },
        },
        series: [{
          name: '数量',
          type: 'bar',
          data: this.scoreData.map(item => item.value),
          itemStyle: {
            normal: {
              color: "#FFb6ce",
              lineStyle: {
                color: "#FFb6ce",
              }
            }
          }
        }]
      };
      this.chart = Chart.init(this.$refs.difficultychart)
      this.chart.setOption(difficultyOption)
    },
    // 难度级别的题目占题库总数
    drawPieChart() {
      // 计算每个难度级别的比例  
      // 指定图表的配置项和数据  
      let typeOption = {
        title: {
          text: '考核通过率',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'left',
        },
        series: [
          {
            name: '考核通过率统计',
            type: 'pie',
            radius: '55%',
            center: ['50%', '50%'],
            data: [
              { name: '通过', value: '80' ,itemStyle: {color: 'rgba(75, 192, 192, 1)'}},
              { name: '未通过', value: "10",itemStyle: {color: 'rgba(255, 99, 132, 1)'} },
              { name: '优秀', value: "10",itemStyle: {color: 'rgba(153, 102, 255, 1)'} },
            ].sort(function (a, b) { return a.value - b.value; }),
            roseType: 'radius',
          }
        ],
      };
      //显示图表
      this.chart = Chart.init(this.$refs.typechart)
      this.chart.setOption(typeOption)
    },


  }
};
</script>
<style> 
.stbox {
   width: 100%;
   height: 100%;
   box-sizing: border-box;
 }


 .stsearch {
   text-align: center;
 }

 .text-c {
   text-align: center;
 }

 .st-gbox {
   background-color: #fff;
   margin-top: 20px;
   border-radius: 5px;
   height: 30vh;
   box-sizing: border-box;
   padding: 10px;
 }

 .cavasbox {
   box-sizing: border-box;
   width: 100%;
   height: 100%;
 }

 .canvas {
   width: 100%;
   height: 100%;
 }

 .paybox {
   width: 100%;
   background-color: #fff;
   box-sizing: border-box;
   border-radius: 5px;
   margin-top: 20px;
   height: 32vh;
 }



 .breadcrumb-title {
   margin-top: 10px;
   margin-bottom: 10px;
 }

 .thinking-content {
   /* display: flex;
  align-items: center;
  justify-content: center; */

 }

 .latest-updates-card {
   background-color: #fff;
   border: 1px solid #ddd;
   border-radius: 5px;
   padding: 20px;
   margin-bottom: 20px;
   box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
 }

 .latest-updates-card h2 {
   font-size: 18px;
   margin-bottom: 15px;
 }

 .latest-updates-card ul {
   list-style-type: none;
   padding: 0;
 }

 .latest-updates-card li {
   margin-bottom: 10px;
 }</style>